home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1987 December / 1987-12.d64 / word find (.txt) < prev   
Commodore BASIC  |  2022-09-20  |  4KB  |  109 lines

  1. 10 rem copyright 1987 compute! publications, inc. - all rights reserved
  2. 20 xr=781:yr=782:sr=783:bo=53280:ba=bo+1:q=12
  3. 30 ndx=198:ifpeek(65530)=5then(NULL)15:xr=7:yr=8:sr=5:ndx=208
  4. 40 ifpeek(65530)=164thensr=2037:xr=2035:yr=2036:bo=65305:ba=65301:q=14:ndx=239
  5. 50 pl=65520:pokebo,0:pokeba,0
  6. 60 ifpeek(65530)<>164thens=54272:forn=stos+24:poken,0:next
  7. 70 al$="qazxswedcvfrtgbnhyujmkiolp"
  8. 80 print"[147][156]   copyright 1987 compute! pub., inc."
  9. 90 printtab(10)"all rights reserved":gosub840
  10. 100 print""tab(15)"word find"
  11. 110 input"would you like a time limit (y/n)";tl$
  12. 120 iftl$<>"y"andtl$<>"n"then120
  13. 130 iftl$="n"thentl$="200000":tl=0:goto170
  14. 140 input"how many minutes (1-59)";tl:iftl<1ortl>59then140
  15. 145 if tl<>int(tl) then 140
  16. 150 tl=int(tl):tl$=str$(tl*100):tl$=right$(tl$,len(tl$)-1):tl=1
  17. 160 forww=1to6-len(tl$):tt$=tt$+"0":next:tl$=tt$+tl$
  18. 170 gosub770:gosub680:gosub620:gosub460:gosub420
  19. 180 rem - main loop -
  20. 190 ti$="000000":tu=0:wf=0
  21. 200 pokeyr,27:pokexr,1:syspl:input"[159]row ";ro$:ro=val(ro$)
  22. 210 ifro<1thenbs=0:goto240
  23. 220 ifro>20thenbs=1:goto240
  24. 230 gosub1060:goto250
  25. 240 pokeyr,27:pokexr,1:syspl:print"too ";bs$(bs):gosub1070:gosub1060:goto200
  26. 250 ifti$>tl$thentu=1:goto890
  27. 260 pokeyr,27:pokexr,1:syspl:input"column ";co$:co=val(co$)
  28. 270 ifco<1thenbs=0:goto300
  29. 280 ifco>20thenbs=1:goto300
  30. 290 gosub1060:goto310
  31. 300 pokeyr,27:pokexr,1:syspl:print"too ";bs$(bs):gosub1070:gosub1060:goto250
  32. 310 f=0:fori=1tonw:ifro<>py(i)orco<>px(i)then330
  33. 320 f=2:ift(i)=0thenx1=i:t(i)=1:f=1:i=nw
  34. 330 next:iff=1then360
  35. 340 c$="wrong":iff=2thenc$="that's found"
  36. 350 pokeyr,27:pokexr,1:pokesr,0:syspl:printc$:gosub1070:gosub1060:goto200
  37. 360 fori=0tolen(w$(x1))-1:xp=3+px(x1)+i*dx(tw(x1))
  38. 370 yp=2+py(x1)+i*dy(tw(x1)):gosub960
  39. 380 print"[156]"mid$(w$(x1),i+1,1):gosub1030
  40. 390 next:pokeyr,25:pokexr,2+x1:syspl:printw$(x1):wf=wf+1:ifwf=nwthen880
  41. 400 goto200
  42. 410 rem - fill grid -
  43. 420 fory=1to20:forx=1to20
  44. 430 ifa$(x,y)=""thena$(x,y)=mid$(al$,26*rnd(1)+1,1)
  45. 440 xp=3+x:yp=2+y:gosub960:printa$(x,y):next:next:return
  46. 450 rem - position words -
  47. 460 pw=0
  48. 470 pw=pw+1
  49. 480 px(pw)=int(20*rnd(1)+1):py(pw)=int(20*rnd(1)+1)
  50. 490 dr=int(8*rnd(1)+1):tw(pw)=dr
  51. 500 cx=px(pw)+len(w$(pw))*dx(dr):cy=py(pw)+len(w$(pw))*dy(dr)
  52. 510 ifcx<1orcx>20orcy<1orcy>20then480
  53. 520 f=0:forck=0tolen(w$(pw))-1
  54. 530 z1$=mid$(w$(pw),ck+1,1):z2$=a$(px(pw)+ck*dx(dr),py(pw)+ck*dy(dr))
  55. 540 ifz2$<>""andz1$<>z2$thenf=1
  56. 550 next:iff=1then480
  57. 560 forck=0tolen(w$(pw))-1
  58. 570 z1$=mid$(w$(pw),ck+1,1):a$(px(pw)+ck*dx(dr),py(pw)+ck*dy(dr))=z1$
  59. 580 xp=25:yp=2+pw:gosub960:printw$(pw);:next
  60. 590 ifpw=nwthenreturn
  61. 600 goto470
  62. 610 rem - sort by length -
  63. 620 pokeyr,29:pokexr,1:syspl:print"sorting"
  64. 630 f=0:fori=1tonw-1
  65. 640 iflen(w$(i))<len(w$(i+1))thent$=w$(i+1):w$(i+1)=w$(i):w$(i)=t$:f=1
  66. 650 next:iff=1then630
  67. 660 gosub1060:return
  68. 670 rem - print grid -
  69. 680 print"[147]";
  70. 690 print"[172]";:fori=1to20:print"[162]";:next
  71. 700 print"[187][157]";:fori=1to20:print"[161][146][157]";:next
  72. 710 print"[190][157][157]";:fori=1to20:print"[146][162][157][157]";:next
  73. 720 print"[188][157][145]";:fori=1to20:print"[146][161][157][145]";:next:print""
  74. 730 fori=1to20:nu$=str$(i):nu$=mid$(nu$,2):iflen(nu$)=1thennu$=" "+nu$
  75. 740 xp=1:yp=i+2:gosub960:printnu$:xp=i+3:yp=0:gosub960:printleft$(nu$,1)
  76. 750 xp=i+3:yp=1:gosub960:printright$(nu$,1):next:return
  77. 760 rem - input words -
  78. 770 input"[147]how many words (maximum of 20)";nw:print:ifnw<1ornw>20then770
  79. 780 print"[147]enter each word between 3 and"q
  80. 790 print"characters in length:":fori=1tonw
  81. 800 printi"> ";:inputw$(i)
  82. 810 iflen(w$(i))<3orlen(w$(i))>qthenprintchr$(13)"[145][145][145]":goto800
  83. 820 next:return
  84. 830 rem - set up variables -
  85. 840 dima$(20,20),w$(20),px(20),py(20),dx(8),dy(8),tw(20),t(20)
  86. 850 fori=1to8:readdx(i),dy(i):next:bs$(0)="small  ":bs$(1)="big    ":return
  87. 860 data 0,-1,1,-1,1,0,1,1,0,1,-1,1,-1,0,-1,-1
  88. 870 rem - subroutines -
  89. 880 gosub1070:gosub970
  90. 890 forx1=1tonw:fori=0tolen(w$(x1))-1
  91. 900 xp=3+px(x1)+i*dx(tw(x1)):yp=2+py(x1)+i*dy(tw(x1)):gosub960:print"";
  92. 910 printmid$(w$(x1),i+1,1)
  93. 920 gosub1030
  94. 930 next:xp=25:yp=2+x1:gosub960:printw$(x1):next
  95. 940 pokendx,0:forps=1to5000:next
  96. 950 print"[147]"tab(7)"you didn't finish in time.":goto990
  97. 960 pokesr,0:pokeyr,xp:pokexr,yp:syspl:return
  98. 970 print"[147]":xp=14:yp=12:gosub960:print"you did it!!"
  99. 980 iftl=1thenprint"[149]        and you finished in time!"
  100. 990 xp=6:yp=17:gosub960:print"press space bar[146] to play again"
  101. 1000 geta$:ifa$=" "thenrun
  102. 1010 ifa$<>""thenprint"[147]":end
  103. 1020 goto1000
  104. 1030 ifpeek(65530)=164then(NULL)7:(NULL)3,1000,5:return
  105. 1040 pokes+5,64:pokes+6,0:pokes+24,15:pokes+1,100:pokes,0:pokes+4,129
  106. 1050 forn=1to22:next:pokes+4,0:return
  107. 1060 pokesr,0:pokeyr,27:pokexr,1:syspl:print"            ":return
  108. 1070 fori=1to1000:next:return
  109.